/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：MessageMenuScreen.java <br>
 * 创建时间：2014-8-4 下午3:16:35 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2.community;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.FindListener;
import lostland.gmud.exv2.expand.GeneralMenuScreen;
import lostland.gmud.exv2.ui.NotificationScreen;

/**
 * 类名：MessageMenuScreen <br>
 * 说明：社区查看消息菜单界面
 *
 * @author 12548
 */
public class MessageMenuScreen extends GeneralMenuScreen {

	/**
	 */
	public MessageMenuScreen() {
		super(gets(), "请选择操作");
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.ui.core.ScrollableMenuScreen#onCancel()
	 */
	@Override
	public void onCancel() {
		getGame().popScreen();
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.ui.core.ScrollableMenuScreen#onClick(int)
	 */
	@Override
	public void onClick(int i) {
		switch (i) {
			case 0:
				sent();
				break;
			case 1:
				BmobQuery<MarriageProposing> q = new BmobQuery<>();
				q.addWhereEqualTo("receiver", GmudUser.getInstance());
				q.addWhereEqualTo("stat", 0);
				q.include("sender");

				q.findObjects(getGame(), new FindListener<MarriageProposing>() {

					@Override
					public void onError(int arg0, String arg1) {
						new NotificationScreen("联网错误：" + arg1).pushToGame();
					}

					@Override
					public void onSuccess(List<MarriageProposing> arg0) {
//					getGame().pushScreen(new ReceivedProposingScreen(arg0));
					}
				});
				break;
		}
	}

	/**
	 *
	 */
	protected void sent() {
		BmobQuery<MarriageProposing> q = new BmobQuery<>();
		q.addWhereEqualTo("sender", GmudUser.getInstance());
		q.include("receiver");
		q.findObjects(getGame(), new FindListener<MarriageProposing>() {

			@Override
			public void onError(int arg0, String arg1) {
				new NotificationScreen("联网错误：" + arg1).pushToGame();
			}

			@Override
			public void onSuccess(List<MarriageProposing> arg0) {
//				getGame().pushScreen(new SentProposingScreen(arg0));
			}
		});
	}


	private static ArrayList<String> gets() {
		ArrayList<String> s = new ArrayList<>();
		s.add("发出的求婚");
		s.add("收到的求婚");
		return s;
	}
}
